﻿CREATE TABLE [Queue].[Process]
(
	[ProcessQueueID] BIGINT IDENTITY(1,1) NOT NULL CONSTRAINT [QUEUE_Process_ProcessQueueID] PRIMARY KEY,
	[DownloadQueueID] BIGINT NULL CONSTRAINT [FK_Process_TO_Download_ON_DownloadQueueID] FOREIGN KEY ([DownloadQueueID]) REFERENCES [Queue].[Download]([DownloadQueueID]),
	[ProcessType] NVARCHAR(250) NOT NULL CONSTRAINT [FK_Process_TO_ProcessType_ON_Enum] FOREIGN KEY ([ProcessType]) REFERENCES [Queue].[ProcessType]([Enum]),
	[Result] NVARCHAR(250) NOT NULL CONSTRAINT [QUEUE_Process_Result] DEFAULT ('QUEUED'), 
	[CreatedBy] NVARCHAR(250) NOT NULL CONSTRAINT [QUEUE_Process_CreatedBy] DEFAULT SYSTEM_USER,	
	[DateCreated] DATETIME NOT NULL CONSTRAINT [QUEUE_Process_DateCreated] DEFAULT GETDATE(), 
	[DateDeleted] DATETIME NULL,
	[VersionUser] NVARCHAR(250) NOT NULL CONSTRAINT [QUEUE_Process_VersionUser] DEFAULT SYSTEM_USER,
	[VersionDate] DATETIME NOT NULL CONSTRAINT [QUEUE_Process_VersionDate] DEFAULT GETDATE()
)